<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css"/>




  <link href="//fonts.useso.com/css?family=Lato:300,400,700,400italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">



<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=0.5.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="APK,Android,签名," />





  <link rel="alternate" href="/atom.xml" title="Lippi-浮生志" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=0.5.0" />






<meta name="description" content="App为什么需要签名？
对Apk的完整性和发布机构唯一性的校验
签名之后无法阻止APK被人修改，但修改后再签名就和原先的签名不一致，可以避免有些人用相同包名的APK来替换已有的应用
相同签名的升级软件可以覆盖安装旧版本的软件
签名的私钥在开发者那里，公钥打包在APK内，不同公钥对应不同私钥，通过比较公钥可以判断私钥是否一致
允许代码和数据共享。android中提供了一个基于签名的Permissio">
<meta property="og:type" content="article">
<meta property="og:title" content="Android APK签名详解">
<meta property="og:url" content="http://www.ezlippi.com/blog/2016/03/android-apk-signing.html">
<meta property="og:site_name" content="Lippi-浮生志">
<meta property="og:description" content="App为什么需要签名？
对Apk的完整性和发布机构唯一性的校验
签名之后无法阻止APK被人修改，但修改后再签名就和原先的签名不一致，可以避免有些人用相同包名的APK来替换已有的应用
相同签名的升级软件可以覆盖安装旧版本的软件
签名的私钥在开发者那里，公钥打包在APK内，不同公钥对应不同私钥，通过比较公钥可以判断私钥是否一致
允许代码和数据共享。android中提供了一个基于签名的Permissio">
<meta property="og:updated_time" content="2016-03-25T02:27:04.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android APK签名详解">
<meta name="twitter:description" content="App为什么需要签名？
对Apk的完整性和发布机构唯一性的校验
签名之后无法阻止APK被人修改，但修改后再签名就和原先的签名不一致，可以避免有些人用相同包名的APK来替换已有的应用
相同签名的升级软件可以覆盖安装旧版本的软件
签名的私钥在开发者那里，公钥打包在APK内，不同公钥对应不同私钥，通过比较公钥可以判断私钥是否一致
允许代码和数据共享。android中提供了一个基于签名的Permissio">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>

  <title> Android APK签名详解 | Lippi-浮生志 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?340874ba9357cbe81570aa4ac1185941";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>






  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner">
<script>
(function(){
    var bp = document.createElement('script');
    bp.src = '//push.zhanzhang.baidu.com/push.js';
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
            
<div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Lippi-浮生志</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu menu-left">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-home fa-fw"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-th fa-fw"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-archive fa-fw"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-tags fa-fw"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-user fa-fw"></i> <br />
            
            关于
          </a>
        </li>
      

      
      
      
    </ul>
  

  
    <div class="site-search">
      
  <form class="site-search-form">
  <input type="text" id="st-search-input" class="st-search-input st-default-search-input" />
</form>

<script type="text/javascript">
  (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
    (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
    e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
  })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

  _st('install', 'fLM9qfxyerC6njvM7usy','2.0.0');
</script>



    </div>
  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Android APK签名详解
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-03-23T19:16:21+08:00" content="2016-03-23">
              2016-03-23
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Android/" itemprop="url" rel="index">
                    <span itemprop="name">Android</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/blog/2016/03/android-apk-signing.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="/blog/2016/03/android-apk-signing.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          
	
	<span id="busuanzi_container_page_pv" class="post-meta-item-text">
		&nbsp; | &nbsp;  
	    <span id="busuanzi_value_page_pv"><i class="fa fa-spinner fa-spin"></i></span> Hits
	</span>
        </div>
      </header>
    
	


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="App为什么需要签名？"><a href="#App为什么需要签名？" class="headerlink" title="App为什么需要签名？"></a>App为什么需要签名？</h2><ol>
<li>对Apk的完整性和发布机构唯一性的校验</li>
<li>签名之后无法阻止APK被人修改，但修改后再签名就和原先的签名不一致，可以避免有些人用相同包名的APK来替换已有的应用</li>
<li>相同签名的升级软件可以覆盖安装旧版本的软件</li>
<li>签名的私钥在开发者那里，公钥打包在APK内，不同公钥对应不同私钥，通过比较公钥可以判断私钥是否一致</li>
<li>允许代码和数据共享。android中提供了一个基于签名的Permission标签。通过允许的设置，我们可以实现对不同App之间的访问和共享，如下：</li>
</ol>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">AndroidManifest.xml：<span class="tag">&lt;<span class="title">permission</span> <span class="attribute">android:protectionLevel</span>=<span class="value">"normal"</span> /&gt;</span></span><br></pre></td></tr></table></figure>
<p>其中protectionLevel标签有4种值：normal(缺省值),dangerous, signature,signatureOrSystem。normal是低风险的，所有的App不能访问和共享此App。dangerous是高风险的，所有的App都能访问和共享此App。signature是指具有相同签名的App可以访问和共享此App。<br><a id="more"></a></p>
<h2 id="使用SDK工具生成的DEBUG-Key签名"><a href="#使用SDK工具生成的DEBUG-Key签名" class="headerlink" title="使用SDK工具生成的DEBUG Key签名"></a>使用SDK工具生成的DEBUG Key签名</h2><p>Android签名有两种方式：DEBUG和RELEASE,在开发测试期间使用DEBUG方式，BUILD时，会自动使用工具KeyTools创建KEY包括别名和密码。每次编译时，都会使用DEBUG的KEY进行签名。<br>在第一次安装Android开发环境的时候，SDK工具已经创建了缺省的keystore/key和账号、密码：</p>
<figure class="highlight vbnet"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Keystore name – <span class="string">"debug.keystore"</span></span><br><span class="line">Keystore password – <span class="string">"android"</span></span><br><span class="line"><span class="keyword">Key</span> <span class="keyword">alias</span> – <span class="string">"androiddebugkey"</span></span><br><span class="line"><span class="keyword">Key</span> password – <span class="string">"android"</span></span><br><span class="line">CN – <span class="string">"CN=Android Debug,O=Android,C=US"</span></span><br></pre></td></tr></table></figure>
<p>keystore其实就是一个文件，存放以上信息的文件，由于使用了加密难以看懂。DEBUG模式的签名只有365天有效期,过了有效期，编译会出错。但不用担心，只要将debug.keystore文件删除后，下次BUILD会自动生成的keystore和key的。debug.keystore文件一般在/home/username/.android目录下。</p>
<h2 id="使用java命令行工具"><a href="#使用java命令行工具" class="headerlink" title="使用java命令行工具"></a>使用java命令行工具</h2><h3 id="使用Keytool生成key文件"><a href="#使用Keytool生成key文件" class="headerlink" title="使用Keytool生成key文件"></a>使用Keytool生成key文件</h3><p>创建key，需要用到keytool(位于JAVA_HOME\jre\bin目录下),在Shell中输入：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">keytool -genkey -alias android.keystore -keyalg RSA -validity <span class="number">36500</span> -keystore android.keystore</span><br></pre></td></tr></table></figure>
<p>命令行参数解释：</p>
<figure class="highlight haml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">-<span class="ruby"><span class="symbol">genkey:</span>产生秘钥</span><br><span class="line"></span>-<span class="ruby"><span class="keyword">alias</span> android.keystore 别名 android.keystore</span><br><span class="line"></span>-<span class="ruby">keyalg <span class="constant">RSA</span> 使用<span class="constant">RSA</span>算法对签名加密</span><br><span class="line"></span>-<span class="ruby">validity <span class="number">36500</span> 有效期限</span><br><span class="line"></span>-<span class="ruby">keystore android.keystore  存储的文件名</span></span><br></pre></td></tr></table></figure>
<h3 id="使用-jarsigner签名"><a href="#使用-jarsigner签名" class="headerlink" title="使用 jarsigner签名"></a>使用 jarsigner签名</h3><p>jarsigner在目录JAVA_HOME\bin下，在Shell中输入：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">jarsigner -verbose -keystore android.keystore -signedjar android_signed.apk android.apk android.keystore</span><br></pre></td></tr></table></figure>
<p>命令行参数解释：</p>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">-verbose 输出签名的详细信息</span><br><span class="line">-keystore  android<span class="class">.keystore</span> 密钥库位置</span><br><span class="line">-signedjar android_signed<span class="class">.apk</span> android<span class="class">.apk</span> android<span class="class">.keystore</span> 正式签名，三个参数中依次为签名后产生的文件android_signed，要签名的文件android.apk和密钥库android.keystore</span><br></pre></td></tr></table></figure>
<h3 id="zipalign压缩对齐优化APK文件"><a href="#zipalign压缩对齐优化APK文件" class="headerlink" title="zipalign压缩对齐优化APK文件"></a>zipalign压缩对齐优化APK文件</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">zipalign</span> <span class="tag">-v</span> 4 <span class="tag">android_signed</span><span class="class">.apk</span> <span class="tag">release</span><span class="class">.apk</span></span><br></pre></td></tr></table></figure>
<p>zipalign能够使apk文件中未压缩的数据在4个字节边界上对齐，这样android系统可以使用mmap()函数读取文件，在读取资源上获得较高的性能。</p>
<p>android系统中的Davlik虚拟机使用自己专有的格式DEX，DEX的结构是紧凑的，为了让运行时的性能更好，可以进一步用”对齐”进一步优化，但是大小一般会有所增加。</p>
<h2 id="使用Gradle完成签名"><a href="#使用Gradle完成签名" class="headerlink" title="使用Gradle完成签名"></a>使用Gradle完成签名</h2><p>前面已经介绍了DEBUG模式的签名，这里主要讲Release模式：<br>在Module的build.gradle文件的android配置代码块添加如下内容：</p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line">android&#123;</span><br><span class="line">    signingConfigs &#123;</span><br><span class="line">        debug &#123;</span><br><span class="line">            storeFile <span class="keyword">file</span>(<span class="string">"/home/lippi/.android/debug.keystore"</span>)</span><br><span class="line">        &#125;</span><br><span class="line">        relealse &#123;</span><br><span class="line">            <span class="comment">//这样写就得把demo.jk文件放在项目目录</span></span><br><span class="line">            storeFile <span class="keyword">file</span>(<span class="string">"android.keystore"</span>)</span><br><span class="line">            storePassword <span class="string">"android"</span></span><br><span class="line">            keyAlias <span class="string">"lippi"</span></span><br><span class="line">            keyPassword <span class="string">"password"</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">   buildTypes &#123;</span><br><span class="line">        debug &#123;</span><br><span class="line">            <span class="comment">// 显示Log</span></span><br><span class="line">            buildConfigField <span class="string">"boolean"</span>, <span class="string">"LOG_DEBUG"</span>, <span class="string">"true"</span></span><br><span class="line"></span><br><span class="line">            versionNameSuffix <span class="string">"-debug"</span></span><br><span class="line">            minifyEnabled <span class="keyword">false</span></span><br><span class="line">            zipAlignEnabled <span class="keyword">false</span></span><br><span class="line">            shrinkResources <span class="keyword">false</span></span><br><span class="line">            signingConfig signingConfigs.debug</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        release &#123;</span><br><span class="line">            <span class="comment">// 不显示Log</span></span><br><span class="line">            buildConfigField <span class="string">"boolean"</span>, <span class="string">"LOG_DEBUG"</span>, <span class="string">"false"</span></span><br><span class="line">            <span class="comment">//混淆</span></span><br><span class="line">            minifyEnabled <span class="keyword">true</span></span><br><span class="line">            <span class="comment">//Zipalign优化</span></span><br><span class="line">            zipAlignEnabled <span class="keyword">true</span></span><br><span class="line"></span><br><span class="line">            <span class="comment">// 移除无用的resource文件</span></span><br><span class="line">            shrinkResources <span class="keyword">true</span></span><br><span class="line">            <span class="comment">//前一部分代表系统默认的android程序的混淆文件，该文件已经包含了基本的混淆声明</span></span><br><span class="line">            proguardFiles getDefaultProguardFile(<span class="string">'proguard-android.txt'</span>), <span class="string">'proguard.cfg'</span></span><br><span class="line">            <span class="comment">//签名</span></span><br><span class="line">            signingConfig signingConfigs.relealse</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>执行gradle 命令，</p>
<figure class="highlight crystal"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$ </span>gradle assembleRelease</span><br></pre></td></tr></table></figure>
<p>编译并发布。 在build/outputs/apk/ 下能看到未签名的apk 和 已经签名的apk。如果未用签名文件，使用debug mode的debug签名，那就会生成一个debug签名的apk。</p>
<h3 id="签名密码放在Gradle文件中不安全"><a href="#签名密码放在Gradle文件中不安全" class="headerlink" title="签名密码放在Gradle文件中不安全"></a>签名密码放在Gradle文件中不安全</h3><p>可以改成下面这样的格式这样在执行命令时，就会被要求输入密码</p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">signingConfigs &#123; </span><br><span class="line">    myConfig &#123; </span><br><span class="line">        storeFile <span class="keyword">file</span>(<span class="string">"android.keystore"</span>)  </span><br><span class="line">        storePassword System.console().readLine(<span class="string">"\ninput Keystore password: "</span>)  </span><br><span class="line">        keyAlias <span class="string">"lippi"</span>  </span><br><span class="line">        keyPassword System.console().readLine(<span class="string">"\n input Key password: "</span>)  </span><br><span class="line">    &#125; </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="使用Android-Studio自带的签名工具"><a href="#使用Android-Studio自带的签名工具" class="headerlink" title="使用Android Studio自带的签名工具"></a>使用Android Studio自带的签名工具</h2><p>菜单Build &gt; Generate Signed APK,具体的就不介绍了，看了前面的部分应该很简单完成。</p>

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/APK/" rel="tag">#APK</a>
          
            <a href="/tags/Android/" rel="tag">#Android</a>
          
            <a href="/tags/签名/" rel="tag">#签名</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2016/03/android-apk-classy.html" rel="next" title="Android反编译(逆向)教程">
                <i class="fa fa-chevron-left"></i> Android反编译(逆向)教程
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="/blog/2016/03/android-apk-signing.html"
     data-title="Android APK签名详解"
     data-content=""
     data-url="http://www.ezlippi.com//blog/2016/03/android-apk-signing.html">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          

  <p>热评文章</p>
  <div class="ds-top-threads" data-range="weekly" data-num-items="4"></div>


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="/blog/2016/03/android-apk-signing.html"
           data-title="Android APK签名详解" data-url="http://www.ezlippi.com//blog/2016/03/android-apk-signing.html">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.jpg"
               alt="EZLippi" />
          <p class="site-author-name" itemprop="name">EZLippi</p>
          <p class="site-description motion-element" itemprop="description">Easy Lippi</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">63</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>
          
          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">22</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">69</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/EZLippi" target="_blank">
                  
                    <i class="fa fa-github"></i> GitHub
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/ouyanglip" target="_blank">
                  
                    <i class="fa fa-weibo"></i> weibo
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/lippi-ouyang" target="_blank">
                  
                    <i class="fa fa-weibo"></i> zhihu
                  
                </a>
              </span>
            
          
        </div>

        
        

        <div class="links-of-author motion-element">
          
            <p class="site-author-name">友情链接</p>
            
              <span class="links-of-author-item">
                <a href="http://szhshp.org" target="_blank">szhshp的博客</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.zhihu.com/people/lippi-ouyang" target="_blank">友链出租</a>
              </span>
            
          
        </div>

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc-indicator-top post-toc-indicator">
            <i class="fa fa-angle-double-up"></i>
          </div>
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#App为什么需要签名？"><span class="nav-number">1.</span> <span class="nav-text">App为什么需要签名？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用SDK工具生成的DEBUG-Key签名"><span class="nav-number">2.</span> <span class="nav-text">使用SDK工具生成的DEBUG Key签名</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用java命令行工具"><span class="nav-number">3.</span> <span class="nav-text">使用java命令行工具</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#使用Keytool生成key文件"><span class="nav-number">3.1.</span> <span class="nav-text">使用Keytool生成key文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用-jarsigner签名"><span class="nav-number">3.2.</span> <span class="nav-text">使用 jarsigner签名</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#zipalign压缩对齐优化APK文件"><span class="nav-number">3.3.</span> <span class="nav-text">zipalign压缩对齐优化APK文件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用Gradle完成签名"><span class="nav-number">4.</span> <span class="nav-text">使用Gradle完成签名</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#签名密码放在Gradle文件中不安全"><span class="nav-number">4.1.</span> <span class="nav-text">签名密码放在Gradle文件中不安全</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用Android-Studio自带的签名工具"><span class="nav-number">5.</span> <span class="nav-text">使用Android Studio自带的签名工具</span></a></li></ol></div>
            
          </div>
          <div class="post-toc-indicator-bottom post-toc-indicator">
            <i class="fa fa-angle-double-down"></i>
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2014 - 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">EZLippi</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
   托管在 -
  <a class="theme-link" href="https://github.com/EZLippi/EZLippi.github.io">
    Github
  </a>

</div>
<div class="theme-info">
<span id="busuanzi_container_site_pv">
    &nbsp; | &nbsp;本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
</div>
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>



      </div>
    </footer>

    <div class="back-to-top"></div>
  </div>

  


  



  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  <script type="text/javascript" src="/vendors/velocity/velocity.min.js"></script>

  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js"></script>

  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=0.5.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=0.5.0"></script>



  
  

  
  
<script type="text/javascript" src="/js/src/scrollspy.js?v=0.5.0"></script>

<script type="text/javascript" id="sidebar.toc.highlight">
  $(document).ready(function () {
    var tocSelector = '.post-toc';
    var $tocSelector = $(tocSelector);
    var activeCurrentSelector = '.active-current';

    $tocSelector
      .on('activate.bs.scrollspy', function () {
        var $currentActiveElement = $(tocSelector + ' .active').last();

        removeCurrentActiveClass();
        $currentActiveElement.addClass('active-current');

        $tocSelector[0].scrollTop = $currentActiveElement.position().top;
      })
      .on('clear.bs.scrollspy', function () {
        removeCurrentActiveClass();
      });

    function removeCurrentActiveClass () {
      $(tocSelector + ' ' + activeCurrentSelector)
        .removeClass(activeCurrentSelector.substring(1));
    }

    function processTOC () {
      getTOCMaxHeight();
      toggleTOCOverflowIndicators();
    }

    function getTOCMaxHeight () {
      var height = $('.sidebar').height() -
                   $tocSelector.position().top -
                   $('.post-toc-indicator-bottom').height();

      $tocSelector.css('height', height);

      return height;
    }

    function toggleTOCOverflowIndicators () {
      tocOverflowIndicator(
        '.post-toc-indicator-top',
        $tocSelector.scrollTop() > 0 ? 'show' : 'hide'
      );

      tocOverflowIndicator(
        '.post-toc-indicator-bottom',
        $tocSelector.scrollTop() >= $tocSelector.find('ol').height() - $tocSelector.height() ? 'hide' : 'show'
      )
    }

    $(document).on('sidebar.motion.complete', function () {
      processTOC();
    });

    $('body').scrollspy({ target: tocSelector });
    $(window).on('resize', function () {
      if ( $('.sidebar').hasClass('sidebar-active') ) {
        processTOC();
      }
    });

    onScroll($tocSelector);

    function onScroll (element) {
      element.on('mousewheel DOMMouseScroll', function (event) {
          var oe = event.originalEvent;
          var delta = oe.wheelDelta || -oe.detail;

          this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
          event.preventDefault();

          toggleTOCOverflowIndicators();
      });
    }

    function tocOverflowIndicator (indicator, action) {
      var $indicator = $(indicator);
      var opacity = action === 'show' ? 1 : 0;
      $indicator.velocity ?
        $indicator.velocity('stop').velocity({
          opacity: opacity
        }, { duration: 100 }) :
        $indicator.stop().animate({
          opacity: opacity
        }, 100);
    }

  });
</script>

<script type="text/javascript" id="sidebar.nav">
  $(document).ready(function () {
    var html = $('html');
    var TAB_ANIMATE_DURATION = 200;
    var hasVelocity = $.isFunction(html.velocity);

    $('.sidebar-nav li').on('click', function () {
      var item = $(this);
      var activeTabClassName = 'sidebar-nav-active';
      var activePanelClassName = 'sidebar-panel-active';
      if (item.hasClass(activeTabClassName)) {
        return;
      }

      var currentTarget = $('.' + activePanelClassName);
      var target = $('.' + item.data('target'));

      hasVelocity ?
        currentTarget.velocity('transition.slideUpOut', TAB_ANIMATE_DURATION, function () {
          target
            .velocity('stop')
            .velocity('transition.slideDownIn', TAB_ANIMATE_DURATION)
            .addClass(activePanelClassName);
        }) :
        currentTarget.animate({ opacity: 0 }, TAB_ANIMATE_DURATION, function () {
          currentTarget.hide();
          target
            .stop()
            .css({'opacity': 0, 'display': 'block'})
            .animate({ opacity: 1 }, TAB_ANIMATE_DURATION, function () {
              currentTarget.removeClass(activePanelClassName);
              target.addClass(activePanelClassName);
            });
        });

      item.siblings().removeClass(activeTabClassName);
      item.addClass(activeTabClassName);
    });

    $('.post-toc a').on('click', function (e) {
      e.preventDefault();
      var targetSelector = NexT.utils.escapeSelector(this.getAttribute('href'));
      var offset = $(targetSelector).offset().top;
      hasVelocity ?
        html.velocity('stop').velocity('scroll', {
          offset: offset  + 'px',
          mobileHA: false
        }) :
        $('html, body').stop().animate({
          scrollTop: offset
        }, 500);
    });

    // Expand sidebar on post detail page by default, when post has a toc.
    NexT.motion.middleWares.sidebar = function () {
      var $tocContent = $('.post-toc-content');

      if (CONFIG.sidebar.display === 'post' || CONFIG.sidebar.display === 'always') {
        if ($tocContent.length > 0 && $tocContent.html().trim().length > 0) {
          NexT.utils.displaySidebar();
        }
      }
    };
  });
</script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=0.5.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"ezlippi"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
  





  
  

  
  


</body>
</html>
